package com.tbit.api;

import cn.hutool.core.bean.BeanUtil;
import com.tbit.manager.api.UsageApi;
import com.tbit.uqbike.manager.exception.BaseException;
import com.tbit.uqbike.object.pojo.vo.UsageMessageVO;
import com.tbit.uqbike.service.business.UsageRemindService;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 用量获取实现类 openfeign接口
 * @author <a href="mailto:liu.haoxiang@tbit.com.cn">BUGXiang</a>
 * @version 1.0
 * @since 2024-10-22
 */
@RestController
public class UsageApiImpl implements UsageApi {

    @Resource
    private UsageRemindService usageRemindService;

    @Override
    public Map<String, Object> getMessage(Integer brandId) {
        if (brandId == null) {
            throw new BaseException("品牌id不能为空");
        }
        UsageMessageVO data = usageRemindService.getMessage(brandId).getData();
        return BeanUtil.beanToMap(data);
    }
}
